﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Prowess.OIS.Component.View.Interface;
using Prowess.OIS.Component.Presenter.Interface;
using Prowess.OIS.Component.PresenterFactory;

namespace Prowess.OIS.Component.View
{
    /// <summary>
    /// Interaction logic for WndConfigurations.xaml
    /// </summary>
    public partial class WndConfigurations : Window, IConfiguration
    {
        private IDatabaseConfigurationPresenter presenter;
        public WndConfigurations()
        {
            InitializeComponent();
        }

        public string ServerName
        {
            get
            {
                return tbServerName.Text;
            }
            set
            {
                tbServerName.Text = value;
            }
        }

        public string UserName
        {
            get
            {
                return tbUserName.Text;
            }
            set
            {
                tbUserName.Text = value;
            }
        }

        public string PassWord
        {
            get
            {
                return tbPassword.Password;
            }
            set
            {
                tbPassword.Password = value;
            }
        }

        public bool CreateDatabaseStatus
        {            
            set
            {
                btnCreateDatabase.IsEnabled = value;
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            presenter = DatabaseConfigPresenterFactory.GetDatabasePresenter(this);
            presenter.FillData();
        }

        private void btnTestConnection_Click(object sender, RoutedEventArgs e)
        {
            if (presenter!=null)
            {
                presenter.TestConnection();
            }            
        }

        private void btnCreateDatabase_Click(object sender, RoutedEventArgs e)
        {
            if (presenter != null)
            {
                presenter.CreateDatabase();
            }
        }
    }
}
